import 'package:codemode/views/LoadingDialog.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class MyLoadingDialog {
  static bool isLoading = false;

  static void showLoading(BuildContext context, String msg, {Function close}) {
    if (!isLoading) {
      isLoading = true;
      showDialog(
          context: context,
          barrierDismissible: false,
          builder: (BuildContext context) {
            return new LoadingDialog(text: msg);
          }).then((v) {
        isLoading = false;
        if (close != null) {
          close();
        }
        print("ddd");
      });
    }
  }

  static void hideLoading(BuildContext context) {
    if (isLoading) {
      Navigator.of(context).pop();
    }
  }
}
